﻿/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xoskit.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __XOS_BOX_LOCK_LOCK_OBJ_H__
#define __XOS_BOX_LOCK_LOCK_OBJ_H__

#include "../tools/head.h"

namespace xos
{
    class i_lock;
}

namespace xos_box
{
    // 
    // lock obj
    // 
    class lock_obj : public xos_stl::mem_item< xos::release_impl< lock_obj >, thread_lock >,
        public xos_box::i_lock_obj
    {
    public:
        typedef xos::release_impl< lock_obj > T;

    public:
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //

        static int get_addr( POOL *** pppPool, LIST *** pppList );

    public:
        lock_obj();
        ~lock_obj();

    protected:
        thread_lock m_lock;
        void * m_pObj;

    public:
        void * set( void * pData );
        void * get();

    protected:
        int init_data();

    public:
        int init();
        int term();

    };
}

#endif // __XOS_BOX_LOCK_LOCK_OBJ_H__
